<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>异步</title>
</head>
<body>
    <script>
         
             let promise = new Promise((resolve,rejected)=>{
                if(1)
                {
                   setTimeout(() => {
                       resolve("成功");
                   }, 3000);
                }
                else{
                    rejected("错误代码");
                }
            })
               console.log("1");
            promise.then(function(sucinfo){
                   console.log(`成功${sucinfo}`);
            }).catch(function(err){
                console.log(`失败${err}`)
            })
            console.log("2");
            

            //执行结果是 1  2 成功成功
    </script>
</body>
</html>